﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace game_source_manager.utilities
{
    class directory
    {
        //public attributes
        public string path
        {
            set
            {
                if (Directory.Exists(value)){
                    _dict_info = new DirectoryInfo(value);
                    _dict_path = value;
                    is_exist = true;
                }
                else{
                    Console.WriteLine("{0} is not exist!!!", value);
                }
            }
            get
            {
                return _dict_path;
            }
        }
        public List<file> all_files
        {
            get
            {
                return _all_files;
            }
        }
    
        public bool is_exist = false;
        //public method
        //constructor
        public directory(string dict_path)
        {
            path = dict_path;
            if (is_exist)
            {
                _get_all_files();
            }
        }
        //private attributes
        private DirectoryInfo _dict_info;
        private string _dict_path = "";
        private List<file> _all_files = new List<file>();
        //private method
        private void _get_all_files()
        {
            foreach (FileInfo file in _dict_info.GetFiles())
            {
                _all_files.Add(new file(file.FullName));
            }

            foreach (DirectoryInfo folder in _dict_info.GetDirectories())
            {
                foreach (FileInfo file in folder.GetFiles())
                {
                    _all_files.Add(new file(file.FullName));
                }
            }
        }
    }
}
